Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for float16 matmul #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LaurentMazare
Copy link

As mentioned in #41 it would be nice to have support for half precision matmul (especially when using mkl).
This PR adds it and goes together with blas-lapack-rs/blas-sys#21 on the sys side. The blas-sys version has been bumped to reflect the new requirement.

Let me know if there is anything that could be done to improve this PR or the blas-sys one, or if you see any different way to get this working.
Thanks,

Note that this has been tested in a very simple way via the following:

extern crate intel_mkl_src;

use half::f16;

fn main() {
    println!("Hello, world!");
    let alpha = f16::ONE;
    let beta = f16::ZERO;
    let a = vec![f16::from_f64(0.5)];
    let b = vec![f16::from_f64(0.5)];
    let mut c = vec![f16::from_f64(0.5)];
    unsafe {
        blas::hgemm(
            b'N',
            b'N',
            1,
            1,
            1,
            alpha,
            a.as_slice(),
            1,
            b.as_slice(),
            1,
            beta,
            c.as_mut_slice(),
            42,
        )
    };
    println!("{c:?}");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant